package com.define.commons.demo;

import com.define.commons.demo.datax.dao.ProcessMapper;
import com.define.commons.demo.datax.dao.ProcessOnMapper;
import com.define.commons.demo.datax.domain.Process;
import com.define.commons.demo.datax.domain.ProcessOn;
import com.gitee.fastmybatis.core.query.Query;
import org.apache.commons.lang3.RandomUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;
import java.util.UUID;

/**
 * @Author xiewenlong
 * @Date 2018/12/20
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class GeneratorData {
    @Autowired
    private ProcessMapper processMapper;
    @Autowired
    private ProcessOnMapper processOnMapper;

    public void before(){
        List<Process> processs = processMapper.list(new Query());
        List<ProcessOn> processOns = processOnMapper.list(new Query());
        for (ProcessOn p : processOns) {
            System.out.println(p.getProcess());
        }
    }

    @Test
    public void data(){
        before();
        for (int i = 0; i < 1000; i++) {
            ProcessOn processOn = new ProcessOn();
            processOn.setName(UUID.randomUUID().toString().substring(6));
            processOn.setSex((1 == RandomUtils.nextInt(1,3))?"男":"女");
            processOn.setAge(i);
            processOnMapper.save(processOn);
        }
        before();
    }
}
